import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Test1 {


    //蓝桥，最大的卡牌价值，贪心
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();
        long sum = 0;
        List<Integer> diffs = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            int a = s.nextInt();
            sum+=a;
        }
        for (int i = 0; i < n; i++) {
            int b = s.nextInt();
            diffs.add(b-s.nextInt());
        }
        diffs.sort((x,y)->y-x);

        for (int i = 0; i < k &&i<diffs.size(); i++) {
            int diff = diffs.get(i);
            if (diff>0) sum+=diff;
            else break;
        }
        System.out.println(sum);
    }

    //蓝桥，分巧克力 二分
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[][] chocolates = new int[N][2];
        int maxlen = 0;

        for(int i = 0;i<N;i++){
            int h = scan.nextInt();
            int w = scan.nextInt();
            chocolates[i][0] = h;
            chocolates[i][1] = w;
            maxlen = Math.max(maxlen,Math.max(h,w));
        }

        int l = 1;
        int r = maxlen;
        int ans = 0;

        while(l <= r){
            int mid = l + (r-l)/2;
            int cnt = 0;

            for(int[] choco : chocolates){
                cnt += (choco[0]/mid) * (choco[1]/mid);
                if(cnt >= K) break;
            }

            if(cnt >= K){
                ans = mid;
                l = mid+1;
            }else{
                r = mid-1;
            }
        }

        System.out.println(ans);
        scan.close();
    }
}
